<?php
// Copyright 2019 Hackware SpA <human@hackware.cl>
// This file is part of "Hackware Web Services Payment" and licensed under
// the terms of the GNU Affero General Public License version 3, or (at your
// option) a later version. You should have received a copy of this license
// along with the software. If not, see <https://www.gnu.org/licenses/>.

namespace Hawese\Payment\Exceptions;

use RuntimeException;

class UnexpectedResponseException extends RuntimeException
{
    private $detail;
    public $status;

    public function __construct($response)
    {
        $this->status = $response->getStatusCode();

        parent::__construct(
            "Unexpected HTTP response ($this->status)", // message
            2001 // code
        );

        $this->detail = [
            'body' => $response->getBody(),
        ];
    }

    public function getDetail()
    {
        return $this->detail;
    }
}
